import os

import pytest
import yagmail,HTMLTestRunner_cn,logging

class Tools():
    def BaoGao(self):
        baogao = HTMLTestRunner_cn.HTMLTestRunner(open(r"E:\Auto_Wms\Api_A3mall\reports\A3mall.html",'w'),title='A3mall接口测试报告',description='A3mall接口测试报告')
        return baogao

    def email(self):
        email = yagmail.SMTP(user="3484055372@qq.com",password='uzepywemurpxcigg',host="smtp.qq.com")
        email.send(to='3484055372@qq.com',subject='A3mall测试邮件',contents=['A3mall测试报告',r'E:\Auto_Wms\Api_A3mall\reports\A3mall.html'])

        return email


    def Log(self):
            logging.basicConfig(filename=r'E:\Auto_Wms\Api_A3mall\reports\A3mall.log',filemode='a+',level=logging.DEBUG,
                                format='%(filename)s %(levelname)s %(asctime)s %(message)s %(lineno)d')





if __name__ == '__main__':
    Tools().Log()
    pytest.main([r"E:\Auto_Wms\Api_A3mall\case\test_A3mall.py",'-s',r'--html=E:\Auto_Wms\Api_A3mall\reports\A3mall','--clean-alluredir',r'--alluredir=E:\Auto_Wms\Api_A3mall\reports\report'])
    os.system(r'allure generate -o .html E:\Auto_Wms\Api_A3mall\reports\report E:\Auto_Wms\Api_A3mall\reports\html --clean')
    Tools().email()





